<?php
//接收要删除的ID
$news_id = $_POST['data'];
//连接数据库
$dbh = new PDO('mysql:host=127.0.0.1;dbname=1105', "root", "root");
//查询的sql语句
$sql = "delete from news where news_id = $news_id";
//执行sql语句
$res = $dbh->exec($sql);
//判断是否添加成功
if($res){
    $arr['code'] = 0;
    $arr['msg'] = '删除成功';
    $arr['data'] = [];
}else{
    $arr['code'] = 1;
    $arr['msg'] = '删除失败';
    $arr['data'] = [];
}
//返回json格式的数据
echo json_encode($arr);
